package cn.genmer.test.security.threadpool;

import com.sun.jmx.snmp.Timestamp;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

@SpringBootTest
@Component
public class LocalDateTest2 {
    int x=12;
    public static void main(String[] args) throws Exception {


    }

    @Test
    public void nowDateTimeStamp(){
        Timestamp d = new Timestamp(System.currentTimeMillis());
        System.out.println(d);
    }

    /**
     * 返回当前系统的UTC时间
     * @return
     */
    public static String getCurrentTimeUTC() throws Exception {
        String pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
        SimpleDateFormat simpleDateFormat =
                new SimpleDateFormat(pattern);
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

      return simpleDateFormat.format(new Date());
    }

    /**
     * 格式化请求参数 - 阿里云地址标准化API方式调用的方法 - 不使用
     */
    private static final String ENCODING = "UTF-8";
    private static String percentEncode(String value) throws UnsupportedEncodingException
    {
        return value != null ? URLEncoder.encode(value, ENCODING).replace("+", "%20").replace("*", "%2A").replace("%7E", "~") : null;
    }

}
